<%@ page language="java" pageEncoding="UTF-8" trimDirectiveWhitespaces="true" %>
<%@include file="../include/jspheader.jsp" %>
 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>爱波利-背单词</title>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.js" charset="utf-8"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/home.js" charset="utf-8"></script>
<script>
	var ie = navigator.appName == "Microsoft Internet Explorer" ? true : false;
	function fuck(objID) {
		return document.getElementById(objID);
	}
</script>
</head>
<body>
	<script type="text/javascript">
		var controlid = null;
		var currdate = null;
		var startdate = null;
		var enddate = null;
		var yy = null;
		var mm = null;
		var hh = null;
		var ii = null;
		var currday = null;
		var addtime = false;
		var today = new Date();
		var lastcheckedyear = false;
		var lastcheckedmonth = false;
		function _cancelBubble(event) {
			e = event ? event : window.event;
			if (ie) {
				e.cancelBubble = true;
			} else {
				e.stopPropagation();
			}
		}
		function getposition(obj) {
			var r = new Array();
			r['x'] = obj.offsetLeft;
			r['y'] = obj.offsetTop;
			while (obj = obj.offsetParent) {
				r['x'] += obj.offsetLeft;
				r['y'] += obj.offsetTop;
			}
			return r;
		}
		function loadcalendar() {
			s = '';
			s += '<div class="hbj" id="calendar" style="display:none; position:absolute; z-index:9;"  onclick="_cancelBubble(event)">';
			if (ie) {
				s += '<iframe width="238" height="298" src="about:blank" style="position: absolute;z-index:-1;"></iframe>';
			}
			s += '<div  margin-left:1px;"><table class="tableborder" cellspacing="0" cellpadding="0" width="100%" style="text-align: center">';
			s += '<tr align="center" class="header"><td colspan="5" style="text-align: left" class="header"><a style="padding-right:0px;" id="month" title="点击选择月份" href="#" onclick="showdiv(\'month\');_cancelBubble(event);return false"></a>&nbsp;-&nbsp;<a href="#" onclick="showdiv(\'year\');_cancelBubble(event);return false" title="点击选择年份" id="year"></a></td><td class="header"><a href="#" onclick="refreshcalendar(yy, mm-1);return false" title="上一月"><div class="lefts"></div></a></td><td class="header" style="padding-left:8px;"><A href="#" onclick="refreshcalendar(yy, mm+1);return false" title="下一月"><div class="rights"></div></A></td></tr>';
			s += '<tr class="category"><td>Sun</td><td>Mon</td><td>Tue</td><td>Wed</td><td>Thu</td><td>Fri</td><td>Sat</td></tr>';
			for ( var i = 0; i < 6; i++) {
				s += '<tr class="altbg2">';
				for ( var j = 1; j <= 7; j++)
					s += "<td id=d" + (i * 7 + j) + " height=\"19\">0</td>";
				s += "</tr>";
			}
			s += '<tr id="hourminute"><td colspan="7" align="center"><input type="text" size="1" value="" id="hour" onKeyUp=\'this.value=this.value > 23 ? 23 : zerofill(this.value);controlid.value=controlid.value.replace(/\\d+(\:\\d+)/ig, this.value+"$1")\'> 点 <input type="text" size="1" value="" id="minute" onKeyUp=\'this.value=this.value > 59 ? 59 : zerofill(this.value);controlid.value=controlid.value.replace(/(\\d+\:)\\d+/ig, "$1"+this.value)\'> 分</td></tr>';
			s += '</table></div></div>';
			s += '<div id="calendar_year" onclick="_cancelBubble(event)"><div class="col">';
			for ( var k = 1930; k <= 2019; k++) {
				s += k != 1930 && k % 10 == 0 ? '</div><div class="col">' : '';
				s += '<a href="#" onclick="refreshcalendar('
						+ k
						+ ', mm);fuck(\'calendar_year\').style.display=\'none\';return false"><span'
						+ (today.getFullYear() == k ? ' class="today"' : '')
						+ ' id="calendar_year_' + k + '">' + k
						+ '</span></a><br />';
			}
			s += '</div></div>';
			s += '<div id="calendar_month" onclick="_cancelBubble(event)">';
			for ( var k = 1; k <= 12; k++) {
				s += '<a href="#" onclick="refreshcalendar(yy, '
						+ (k - 1)
						+ ');fuck(\'calendar_month\').style.display=\'none\';return false"><span'
						+ (today.getMonth() + 1 == k ? ' class="today"' : '')
						+ ' id="calendar_month_' + k + '">' + k
						+ (k < 10 ? ' ' : '') + ' 月</span></a><br />';
			}
			s += '</div>';
			var nElement = document.createElement("div");
			nElement.innerHTML = s;
			document.getElementsByTagName("body")[0].appendChild(nElement);
			// document.write(s);
			/*document.onclick = function(event) {
			$('calendar').style.display = 'none';
			$('calendar_year').style.display = 'none';
			$('calendar_month').style.display = 'none';
			}*/
			fuck('calendar').onclick = function(event) {
				// _cancelBubble(event);
				//$('calendar_year').style.display = 'none';
				//$('calendar_month').style.display = 'none';
			}
		}
		function parsedate(s) {
			/(\d+)\-(\d+)\-(\d+)\s*(\d*):?(\d*)/.exec(s);
			var m1 = (RegExp.$1 && RegExp.$1 > 1899 && RegExp.$1 < 2101) ? parseFloat(RegExp.$1)
					: today.getFullYear();
			var m2 = (RegExp.$2 && (RegExp.$2 > 0 && RegExp.$2 < 13)) ? parseFloat(RegExp.$2)
					: today.getMonth() + 1;
			var m3 = (RegExp.$3 && (RegExp.$3 > 0 && RegExp.$3 < 32)) ? parseFloat(RegExp.$3)
					: today.getDate();
			var m4 = (RegExp.$4 && (RegExp.$4 > -1 && RegExp.$4 < 24)) ? parseFloat(RegExp.$4)
					: 0;
			var m5 = (RegExp.$5 && (RegExp.$5 > -1 && RegExp.$5 < 60)) ? parseFloat(RegExp.$5)
					: 0;
			/(\d+)\-(\d+)\-(\d+)\s*(\d*):?(\d*)/.exec("0000-00-00 00\:00");
			return new Date(m1, m2 - 1, m3, m4, m5);
		}
		function settime(d) {
			//$('calendar').style.display = 'none';
			controlid.value = yy
					+ "-"
					+ zerofill(mm + 1)
					+ "-"
					+ zerofill(d)
					+ (addtime ? ' ' + zerofill(fuck('hour').value) + ':'
							+ zerofill(fuck('minute').value) : '');
			showWordForDay(controlid.value);
		}
		
		function showWordForDay(date) {
			alert("当前时间：" + date);
			$.get("http://localhost:8080/epower-site-webapp-1.0.0/jsonepowermainword/getEpowerWordForDay.action?date="+ date, null, function(response) {
					if (response.resultCode == 1) {
						var content = response.result.centerContent;
						$("#center").html(content);
							return;
					}
					alert("操作失败");
			});
		}
		
		function showcalendar(event, controlid1, addtime1, startdate1, enddate1) {
			controlid = controlid1;
			addtime = addtime1;
			startdate = /*startdate1 ? parsedate(startdate1) :*/false;
			enddate = /*enddate1 ? parsedate(enddate1) : */false;
			currday = /*controlid.value ? parsedate(controlid.value) : */today;
			hh = currday.getHours();
			ii = currday.getMinutes();
			var p = getposition(controlid);
			fuck('calendar').style.display = 'block';
			fuck('calendar').style.left = p['x'] + 'px';
			fuck('calendar').style.top = (p['y'] + 0) + 'px';
			//_cancelBubble(event);
			refreshcalendar(currday.getFullYear(), currday.getMonth());
			if (lastcheckedyear != false) {
				fuck('calendar_year_' + lastcheckedyear).className = 'default';
				fuck('calendar_year_' + today.getFullYear()).className = 'today';
			}
			if (lastcheckedmonth != false) {
				fuck('calendar_month_' + lastcheckedmonth).className = 'default';
				fuck('calendar_month_' + (today.getMonth() + 1)).className = 'today';
			}
			fuck('calendar_year_' + currday.getFullYear()).className = 'checked';
			fuck('calendar_month_' + (currday.getMonth() + 1)).className = 'checked';
			fuck('hourminute').style.display = addtime ? '' : 'none';
			lastcheckedyear = currday.getFullYear();
			lastcheckedmonth = currday.getMonth() + 1;
		}
		function refreshcalendar(y, m) {
			var x = new Date(y, m, 1);
			var mv = x.getDay();
			var d = x.getDate();
			var dd = null;
			yy = x.getFullYear();
			mm = x.getMonth();
			fuck("year").innerHTML = yy;
			fuck("month").innerHTML = mm + 1 > 9 ? (mm + 1) : '0' + (mm + 1);
			for ( var i = 1; i <= mv; i++) {
				dd = fuck("d" + i);
				dd.innerHTML = " ";
				dd.className = "";
			}
			while (x.getMonth() == mm) {
				dd = fuck("d" + (d + mv));
				dd.innerHTML = '<a href="###" onclick="settime(' + d
						+ ');return false">' + d + '</a>';
				if (x.getTime() < today.getTime()
						|| (enddate && x.getTime() > enddate.getTime())
						|| (startdate && x.getTime() < startdate.getTime())) {
					dd.className = 'expire';
				} else {
					dd.className = 'default';
				}
				if (x.getFullYear() == today.getFullYear()
						&& x.getMonth() == today.getMonth()
						&& x.getDate() == today.getDate()) {
					dd.className = 'today';
					dd.firstChild.title = '今天';
				}
				if (x.getFullYear() == currday.getFullYear()
						&& x.getMonth() == currday.getMonth()
						&& x.getDate() == currday.getDate()) {
					dd.className = 'checked';
				}
				x.setDate(++d);
			}
			while (d + mv <= 42) {
				dd = fuck("d" + (d + mv));
				dd.innerHTML = " ";
				d++;
			}
			if (addtime) {
				fuck('hour').value = zerofill(hh);
				fuck('minute').value = zerofill(ii);
			}
		}
		function showdiv(id) {
			var p = getposition(fuck(id));
			fuck('calendar_' + id).style.left = p['x'] + 'px';
			fuck('calendar_' + id).style.top = (p['y'] + 16) + 'px';
			fuck('calendar_' + id).style.display = 'block';
		}
		function zerofill(s) {
			var s = parseFloat(s.toString().replace(/(^[\s0]+)|(\s+$)/g, ''));
			s = isNaN(s) ? 0 : s;
			return (s < 10 ? '0' : '') + s.toString();
		}
		loadcalendar();
	</script>
	<div id="Mainbody">
  <!--头子开始-->
  <%@include file="../include/top.jsp" %>
  <!--头子结束-->  
   
   <!--左边开始--> 
    <%@include file="../include/left.jsp" %>
    <!--左边结束-->
    
    <!--中间开始-->
	<div class="center" id="center">
    </div>
    <!--中间结束-->
    
    <!--右边开始-->
		<div class="right3">
			<h1 class="history">历史词汇</h1>
			<div id="calendars">
				<script type="text/javascript">
					showcalendar(null, document.getElementById("calendars"));
				</script>
			</div>
			<input name="button" id="button" onclick="showUserCenter()" value="进入个人中心" />
		</div>
		<!--右边结束-->
    
	<div class="clear"></div>
    <%@include file="../include/footer.jsp" %>
</div>

	<div class="loginboxes" id="logindiv">
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td width="331">
					<div class="input1">
						<span>邮箱/用户名：</span><input name="" type="text" />
					</div>
					<div class="input2">
						<span>密码：</span><input name="" type="password" />
					</div>
					<div class="wrongtips">用户名或者密码错误</div>
					<div class="login_button">
						<input type="submit" name="button" id="button" value="登录" />
					</div>
				</td>
				<td class="right"><a href="#">忘记密码？</a><br /> <a href="#">立即注册!</a>
				</td>
			</tr>
		</table>
		<div class="cancel_ico">
			<a href="#"><img onclick="hideUserCenter()" src="<%=request.getContextPath()%>/images/cancel_ico.png" width="28"
				height="28" /> </a>
		</div>
	</div>
</body>
<script type="text/javascript">
	function showUserCenter() {
		$("#logindiv").show();
	}
	
	function hideUserCenter() {
		$("#logindiv").hide();
	}
</script>
</html>
